$ ls
Hello.txt
$ cat Hello.txt
Hello World5!
$ git log --oneline
61d9201 (HEAD -> master) This is 6th commit
5d55ce7 This is 5th commit
c44785d This is 4th commit
03b89c3 This is 3rd commit
1384c30 This is 2nd commit
297d4d3 This is 1st commit
3bd6182 (origin/master) Update Hello.txt
ab6fba2 Update Hello.txt
daf85b3 Welcome To Facebook
9dbfa3f I want change this commit message
82d1f76 This file is for you
$ git reset --hard HEAD~3
HEAD is now at 03b89c3 This is 3rd commit
$ git log --oneline
03b89c3 (HEAD -> master) This is 3rd commit
1384c30 This is 2nd commit
297d4d3 This is 1st commit
3bd6182 (origin/master) Update Hello.txt
ab6fba2 Update Hello.txt
daf85b3 Welcome To Facebook
9dbfa3f I want change this commit message
82d1f76 This file is for you
$ cat Hello.txt
Hello World3!
This is 3rd commit
This is 4th commit
$ git reset --hard 61d9201
HEAD is now at 61d9201 This is 6th commit
$ git log --oneline
61d9201 (HEAD -> master) This is 6th commit
5d55ce7 This is 5th commit
c44785d This is 4th commit
03b89c3 This is 3rd commit
1384c30 This is 2nd commit
297d4d3 This is 1st commit
3bd6182 (origin/master) Update Hello.txt
ab6fba2 Update Hello.txt
daf85b3 Welcome To Facebook
9dbfa3f I want change this commit message
82d1f76 This file is for you
$ cat Hello.txt
Hello World6!
git reflog
$ git reflog
03b89c3 (HEAD -> master) HEAD@{0}: reset: moving to HEAD~3
61d9201 HEAD@{1}: reset: moving to 61d9201
03b89c3 (HEAD -> master) HEAD@{2}: reset: moving to HEAD~3
7974aaf HEAD@{3}: commit (amend): This is 6th commit
61d9201 HEAD@{4}: reset: moving to 61d9201
03b89c3 (HEAD -> master) HEAD@{5}: reset: moving to HEAD~3
61d9201 HEAD@{6}: reset: moving to 61d9201
03b89c3 (HEAD -> master) HEAD@{7}: reset: moving to HEAD~3
03b89c3
是你現在的狀態哦,也就是你Reset過頭的狀態03b89c3
的再上一次就是61d9201
,換句話說,你現在需要回到的就是61d9201
$ git reset --hard 61d9201
HEAD is now at 61d9201 This is 6th commit
$ git log --oneline -g
61d9201 (HEAD -> master) HEAD@{0}: reset: moving to 61d9201
03b89c3 HEAD@{1}: reset: moving to HEAD~3
61d9201 (HEAD -> master) HEAD@{2}: reset: moving to 61d9201
03b89c3 HEAD@{3}: reset: moving to HEAD~3
7974aaf HEAD@{4}: commit (amend): This is 6th commit
61d9201 (HEAD -> master) HEAD@{5}: reset: moving to 61d9201
03b89c3 HEAD@{6}: reset: moving to HEAD~3
61d9201 (HEAD -> master) HEAD@{7}: reset: moving to 61d9201
03b89c3 HEAD@{8}: reset: moving to HEAD~3
Git真有趣呢~